//
//  MemoWidgetView_large.swift
//  memoWidgetExtension
//
//  Created by DaleGuo on 2023/10/11.
//

import SwiftUI

struct MemoWidgetView_large: View {
    var entry: Provider.Entry
    var body: some View {
        VStack(alignment: .leading, spacing: 2) {
            Text(entry.memo.title)
                .lineLimit(1)
                .font(.title3)
                .fontWeight(.bold)
            
            Text(entry.memo.content)
                .font(.system(size: 15))
                .lineLimit(5)
            
            Text(entry.memo.updated_date.formatted(date: .omitted, time: .shortened))
                .font(.caption)
                .foregroundStyle(Color("SecondaryText"))
                
            Divider()
                .padding(.vertical)
            
            // 只显示未完成的todo 到小组件
            ForEach(entry.memo.todos) { todo in
                HStack {
                    Text(todo.content)
                    Spacer()
                    Button(intent: ToggleStateIntent(id: todo.id)) {
                        Image(systemName: todo.is_completed ? "checkmark.circle" : "circle")
                    }
                    .buttonStyle(.plain)
                }
            }
            
            Spacer()
        }
        .frame(maxWidth: .infinity, alignment: .leading)
    }
}
